import * as React from "react";
import { Component } from "react";
import { observer } from "mobx-react";
import { Button } from "antd";
import fly from "../../../../service/Http/fly";
// import { HttpClient } from "../../../../service/Http/HttpClient";
import { getUser } from "../ServeApi";
export interface AjaxOrFetchProps {}

export interface AjaxOrFetchState {}

@observer
class AjaxOrFetch extends Component<AjaxOrFetchProps, AjaxOrFetchState> {
  render() {
    return (
      <>
        <Button
          onClick={() => {
            this.flyioget().then((res) => {
              console.log(res);
            });
          }}
        >
          使用flyIO请求
        </Button>
        <Button
          onClick={() => {
            this.fetchget();
          }}
        >
          使用fetch请求
        </Button>
      </>
    );
  }
  async fetchget() {
    await getUser().catch((err) => {
      console.log(err);
    });
  }
  async flyioget() {
    let res = await fly
      .get("https://api.github.com/users", {})
      .catch((err) => console.log(err));
    return res;
  }
}

export default AjaxOrFetch;
